import 'package:flutter_inappwebview/flutter_inappwebview.dart';

/// https://sps.pheyma.com/wxhhapps/index.html#/Mine/wxUnionId=XXX&flyUnionId=XXX&userId=XXX&platform=android
class Web {
  static const String oldWechatScanUrl = 'https://sps.pheyma.com/wxkanban/wxchatlogin.html';
  static const String oldSpsUrl = 'https://sps.pheyma.com/wxhhapps/index.html#/Mine/';
  static const String oldUserUrl = 'https://sps.pheyma.com/wxhhapps/index.html#/langPage';
  static const String userUrl = 'https://sps.pheyma.com/wxApps/index.html#/langPage';
  static const String indexUrl = 'https://sps.pheyma.com/wxApps/index.html#/home/';
  static const String massageUrl = 'https://sps.pheyma.com/wxApps/index.html#/mine';
  static const String kEqual = '=';
  static const String kAnd = '&';
  static const String kWechatUnionId = 'wxUnionId';
  static const String kLarkUnionId = 'flyUnionId';
  static const String kUserId = 'userId';
  static const String kPlatform = 'platform';



  static const String htmlData =
  """

<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'>
    <meta name='viewport'
        content='width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'>
    <meta http-equiv='X-UA-Compatible' content='ie=edge'>
    <title>摄像头示例</title>
</head>

<body class='text-center'>
    <form id="fileForm">
        <input type="file" id="fileInput" accept="image/*" onchange="getFile()">
    </form>
    <img id="previewImage" alt="">

    <script>
        const fileInput = document.getElementById('fileInput')
        console.log(fileInput.offsetWidth, fileInput.offsetHeight)
        const previewImage = document.getElementById('previewImage')
        previewImage.style.width = fileInput.offsetWidth + 'px';
        previewImage.style.height = fileInput.offsetWidth + 'px';
        previewImage.style.backgroundColor = '#f0f0f0';

        function getFile() {
            // const fileInput = document.getElementById('fileInput')
            // const previewImage = document.getElementById('previewImage')

            const file = fileInput.files[0]

            if (file) {
                const reader = new FileReader()

                reader.onload = function (e) {
                    // 将文件内容转换为 Base64 编码的数据 URL
                    const base64DataUrl = e.target.result

                    // 在预览图像元素中显示 Base64 数据 URL
                    previewImage.src = base64DataUrl;

                    // 输出 Base64 编码的数据 URL 到控制台
                    console.log(base64DataUrl);
                };

                // 获取窗口宽度和高度
                const windowWidth = window.innerWidth;
                const windowHeight = window.innerHeight;

                // 设置图片的最短边适应窗口大小
                if (windowWidth < windowHeight) {
                    previewImage.style.width = '100%';
                    previewImage.style.height = 'auto';
                } else {
                    previewImage.style.height = '100%';
                    previewImage.style.width = 'auto';
                }

                // 读取文件并触发onload事件
                reader.readAsDataURL(file);
            }
        }
    </script>
</body>
</html>

""";
}